// @ts-ignore
import {http,uploadHttp} from "@/http/index";


export const resetHeader=()=>{
  http.defaults.headers.common['Authorization'] = undefined;
};

export const getUserToken: any = (params: any) => {
  return new Promise(async resolve=>{
    const res=await http.post("/cloudApi/api/token/gen", params);
    const data=res?.data
    console.log('gen token data',data)
    if (data?.code === 200) {
      const token=data.token
      const Authorization = `bearer ${token}`
      // 修改token
      http.defaults.headers.common['Authorization'] = Authorization;
      uploadHttp.defaults.headers.common['Authorization'] = Authorization;
    }
    resolve(res)

  })
};

export const loginByToken: any = (params: any) => {
  return http.post("/cloudApi/api/token/login", params);
};

export const registerUser: any = (params: any) => {
  // return http.post("/cat-api/register", params);
  return http.post("/cloudApi/api/register", params);
};

export const getEmailCode: any = (params: any) => {
  return http.post("/cloudApi/api/getEmailCode", params);
};
